accel23 2.2.0
Loading...
Searching...
No Matches
accel23


Accel 23 Click

Accel 23 Click demo application is developed using the NECTO Studio, ensuring compatibility with mikroSDK's open-source libraries and tools. Designed for plug-and-play implementation and testing, the demo is fully compatible with all development, starter, and mikromedia boards featuring a mikroBUS™ socket.


Click Library

  • Author : Stefan Filipovic
  • Date : Jul 2025.
  • Type : I2C/SPI type

Software Support

Example Description

This example demonstrates the use of the Accel 23 Click board by reading acceleration and temperature data from the onboard 3-axis accelerometer. The measured values are displayed via the UART terminal.

Example Libraries

  • MikroSDK.Board
  • MikroSDK.Log
  • Click.Accel23

Example Key Functions

  • accel23_cfg_setup This function initializes Click configuration structure to initial values.
    void accel23_cfg_setup(accel23_cfg_t *cfg)
    Accel 23 configuration object setup function.
    Accel 23 Click configuration object.
    Definition accel23.h:342
  • accel23_init This function initializes all necessary pins and peripherals used for this Click board.
    err_t accel23_init ( accel23_t *ctx, accel23_cfg_t *cfg );
    struct accel23_s accel23_t
    Accel 23 Click context object.
    err_t accel23_init(accel23_t *ctx, accel23_cfg_t *cfg)
    Accel 23 initialization function.
  • accel23_default_cfg This function executes a default configuration of Accel 23 Click board.
    err_t accel23_default_cfg(accel23_t *ctx)
    Accel 23 default configuration function.
  • accel23_get_data This function retrieves acceleration and temperature data from the device.
    err_t accel23_get_data ( accel23_t *ctx, accel23_data_t *data_out );
    err_t accel23_get_data(accel23_t *ctx, accel23_data_t *data_out)
    Accel 23 get all sensor data function.
    Accel 23 Click data structure.
    Definition accel23.h:380

Application Init

Initializes the logger and the Click board and applies the default configuration.

void application_init ( void )
{
log_cfg_t log_cfg;
accel23_cfg_t accel23_cfg;
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, " Application Init " );
// Click initialization.
accel23_cfg_setup( &accel23_cfg );
ACCEL23_MAP_MIKROBUS( accel23_cfg, MIKROBUS_1 );
err_t init_flag = accel23_init( &accel23, &accel23_cfg );
if ( ( I2C_MASTER_ERROR == init_flag ) || ( SPI_MASTER_ERROR == init_flag ) )
{
log_error( &logger, " Communication init." );
for ( ; ; );
}
if ( ACCEL23_ERROR == accel23_default_cfg ( &accel23 ) )
{
log_error( &logger, " Default configuration." );
for ( ; ; );
}
log_info( &logger, " Application Task " );
}
@ ACCEL23_ERROR
Definition accel23.h:394
#define ACCEL23_MAP_MIKROBUS(cfg, mikrobus)
MikroBUS pin mapping.
Definition accel23.h:282
void application_init(void)
Definition main.c:30

Application Task

Reads the acceleration values in X, Y, and Z axis as well as the internal temperature, then displays the results on the UART terminal.

void application_task ( void )
{
accel23_data_t meas_data;
if ( ACCEL23_OK == accel23_get_data ( &accel23, &meas_data ) )
{
log_printf( &logger, " Accel X: %.3f g\r\n", meas_data.accel.x );
log_printf( &logger, " Accel Y: %.3f g\r\n", meas_data.accel.y );
log_printf( &logger, " Accel Z: %.3f g\r\n", meas_data.accel.z );
log_printf( &logger, " Temperature: %.2f degC\r\n\n", meas_data.temperature );
Delay_ms ( 80 );
}
}
@ ACCEL23_OK
Definition accel23.h:393
void application_task(void)
Definition main.c:67
float y
Definition accel23.h:370
float x
Definition accel23.h:369
float z
Definition accel23.h:371
accel23_axes_t accel
Definition accel23.h:381
float temperature
Definition accel23.h:383

Application Output

This Click board can be interfaced and monitored in two ways:

  • Application Output - Use the "Application Output" window in Debug mode for real-time data monitoring. Set it up properly by following this tutorial.
  • UART Terminal - Monitor data via the UART Terminal using a USB to UART converter. For detailed instructions, check out this tutorial.

Additional Notes and Information

The complete application code and a ready-to-use project are available through the NECTO Studio Package Manager for direct installation in the NECTO Studio. The application code can also be found on the MIKROE GitHub account.